/*
 * txdnet.cn tonydon
 * by netbeans ide 7.2
 */
package cn.txdnet.txweb.basedao;

/**
 *
 * @author tangxiaodong
 */
public abstract class AbstractFacade<M extends SqlSessionMgr<S>, S> {

    private M sessionMgr;
    private ThreadLocal<Boolean> invoking = new ThreadLocal<Boolean>();

    protected AbstractFacade(M mgr) {
         sessionMgr = mgr;
    }

    /**
     * 获取关联的sql session mgr
     *
     * @return
     */
    public M getSessionMgr() {
        return  sessionMgr;
    }

    /**
     * 获取数据库会话连接
     * @return 
     */
    protected S getSession() {
        return sessionMgr.getSession();
    }

    boolean isInvoking() {
        return Boolean.TRUE.equals(invoking.get());
    }

    void setInvoking(boolean value) {
        invoking.set(value);
    }
}
